Close
dtSearch Engine API for .NET Framework 2.x-4.x 2023.02
Server::SetEnginePath Method

Specify the folder location of the dtSearch Engine DLL

public void SetEnginePath( ref String p );

 

This method provides a way to specify where the dtSearch Engine is located. If used, it must be called before anything else is done using the dtSearch .NET API.

When to use SetEnginePath

SetEnginePath is only needed when you cannot ensure that the dtSearch Engine DLL will be in the same folder as the .NET API wrapper when your application executes. Currently this occurs in ASP.NET applications and Azure deployments. 

In ASP.NET applications, if you have administrative rights on the server, you can avoid the need to use SetEnginePath by registering the dtSearch Engine DLL using regsvr32, or by copying it into a folder that is on the system PATH.

Why SetEnginePath is needed

The dtSearch .NET API wrapper (dtSearchNetApi2.dll, dtSearchNetApi3.dll, or dtSearchNetApi4.dll) depends on the dtSearch Engine DLL (dten600.dll or dtengine64.dll). In .NET applications, an unmanaged DLL dependency can be separated from the managed assembly when it executes. This occurs in ASP.NET applications when the application is copied to a temporary folder for execution. A DLL dependency of an assembly is not copied in this process. 

If the dtSearch Engine DLL is not on the system PATH, and if its type library is not registered, then it will not be found when the .NET application executes, and the application will fail with an ApiInitializer exception or a FileNotFound exception. 

SetEnginePath provides a way to prevent this even if you do not have administrative rights on the server.

How SetEnginePath works

The .NET API wrapper depends on the dtSearch Engine, but the dtSearch Engine is linked using delayed loading, so it is not needed until you actually create a API object such as SearchJob or IndexJob. If you call Server.SetEnginePath before creating any API objects, then the API wrapper can use the provided directory to load the dtSearch Engine DLL using LoadLibrary, eliminating the need for the dtSearch Engine DLL to be located using the usual DLL search path.